<template>
  <view class="container">
  	<top-back-navbar position="fixed" :title="pageInfos.title" background="#ffffff" color="#000000"></top-back-navbar>
  	<view>
  		<block v-for="(item,index) in list" :key="index">
  			<view class="cz-list-cell" hover-class="uni-list-cell-hover">
  				<view class="cz-triplex-list">
  					<text class="cz-name">{{pageInfos.content}}</text>
  					<text class="cz-jine">¥{{item.num}}</text>
  				</view>
  				<view class="cz-triplex-list">
  					<text class="cz-time">{{item.createtime}}</text>
  					<text class="cz-num">{{item.remark}}</text>
  				</view>
  			</view>
  		</block>
  	</view>
  	<view v-if="list.length == 0" style="padding-top: 300upx;">
  		<image src="/static/searchlist.png" mode=""
  			style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
  		<view style="text-align: center;color: #999;">暂时没有任何记录</view>
  	</view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        title: '',
        list: [],
        page: 1,
        type: 'takeGoods',
        total: 0,
		openid:'',
		pageObj:{
			life_money:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'life_money'
				},
				title:'我的收益-明细',
				content:'我的收益'
			},
			life_equity:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'life_equity'
				},
				title:'分红券-明细',
				content:'分红券'
			},
			life_equity_credits:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'life_equity_credits'
				},
				title:'仓量-明细',
				content:'仓量'
			},
			life_cd:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'life_cd'
				},
				title:'仓单-明细',
				content:'仓单'
			},
			hb_intgral:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'hb_intgral'
				},
				title:'兑换券-明细',
				content:'兑换券'
			},
			suanli_num:{
				api:'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
				query:{
					type:'suanli_num'
				},
				title:'算力池-明细',
				content:'算力池'
			}
		},
		pageInfos:{}
      };
    },
    onLoad(e) {
		console.log(e);
      if (e.type){
		  this.pageInfos=this.pageObj[e.type];
		  this.$GetOpenid().then(res=>{
			  this.openid = res
			  this.getData()
		  })
	  }
    },
    onReachBottom() {
      this.page += 1
      this.getData()
    },
    methods: {
      getData() {
	    uni.showLoading()
		uni.request({
			url: this.$BASE_URL+this.pageInfos.api,
			method: 'POST',
			data: {
				'openid': this.openid,
				page: this.page,
				...this.pageInfos.query
			},
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			success: res => {
				console.log('res',res);
				if(res.data.error == 0){
					this.list=Array.isArray(res.data.list)?res.data.list:[];
				}
			},
			fail: () => {},
			complete: () => {
				uni.hideLoading()
			}
		});
      },
    }
  }
</script>

<style lang="scss">
	.status {
		width: 100%;
		font-size: 24upx;
		background: #e0e0e0;
		text-align: center;
		color: #fff;
		margin-top: 21upx;
	}

	page {
		background-color: #f2f5fa;
		box-sizing: border-box;
	}

	.container {
		padding: 10rpx 30rpx 0 30rpx;
		height: 100%;
	}

	.big_title {
		font-size: 32rpx;
		color: #1e1310;
		font-weight: 600;
		padding: 20rpx 30rpx 10rpx 0;
	}

	.cz-box {
		border-radius: 20rpx;
		padding: 30rpx;
		background: #001b4d;

		.cz-number {
			font-size: 46rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}

		.cz-text {
			font-size: 24rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}
	}
	.cz-box-gf{
		background: transparent url(/static/images/home/gy_qb_bg.png) center no-repeat;
		background-size: 100% 100%;
	}
	.cz-box-jd{
		background-color: #224f91;
	}

	.cz-list-cell {
		padding: 30rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		padding: 20rpx 30rpx;
		margin-top: 30rpx;
		background-color: #fff;

		.cz-triplex-list {
			line-height: 1;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding:10rpx 0;
		}

		.cz-name {
			font-size: 28rpx;
			font-weight: 600;
			color: #1e1310;
		}

		.cz-jine {
			font-size: 28rpx;
			font-weight: 600;
			color: #c30004;
		}

		.cz-time,
		.cz-num {
			font-size: 24rpx;
			color: #888889;
			max-width: 60%;
		}
	}
</style>
